#include "PlayerStateDashRetract.h"
#include "Player.h"


PlayerStateDashRetract::PlayerStateDashRetract(Player* player) : 
PlayerState(player){}

PlayerStateDashRetract::~PlayerStateDashRetract(void){}

void PlayerStateDashRetract::activate()
{
	_player->getAnimationMgr().setAnimation("dash_retract");
	_player->getAnimationMgr().setReverse(true);
}

void PlayerStateDashRetract::deactivate()
{

}

int PlayerStateDashRetract::update()
{	
	if (_player->damageReceived())
		return PSRV_TAKE_DAMAGE;
	if (_player->getAnimationMgr().isDone())
		return PSRV_IDLE;
	else if (_player->getMovementStateX() != MSX_NONE)
		return PSRV_MOVING_GROUND;
	else if (_player->getControlState()->isKeyPressed(CControls::Key(CTRL_JUMP, 0), 0))
	{
		_player->_jumpStartPosition = _player->_position.y;
		return PSRV_JUMPING;
	}
	else if (_player->getControlState()->isKeyPressed(CControls::Key(CTRL_SHOOT, 0), 0))
		return PSRV_ATTACK;
	return PSRV_NOTHING;
}